package com.restaurant.application.qrcode;

import com.google.common.base.Strings;
import com.nebutown.base.ViewSpec;
import com.nebutown.base.data.View;
import com.nebutown.commonunits.utils.DateTimeUtils;
import com.nebutown.commonunits.utils.SnowFlake;
import com.nebutown.generation.basictype.UID;
import com.restaurant.application.qrcode.support.AbstractQrCode;
import com.restaurant.application.qrcode.support.QrCodeData;

import java.util.Objects;

/**
 * @author Administrator
 */
public class QrCodeImpl extends AbstractQrCode {

    @Override
    public void createQr(String qrUrl, UID container, String remark, Integer period) {
        if (Strings.isNullOrEmpty(qrUrl)) {
            throw new IllegalStateException("create qrCode error:qrUrl is null");
        }
        if (Objects.isNull(container)) {
            throw new IllegalStateException("create qrCode error:container is null");
        }
        if (Objects.isNull(remark)) {
            throw new IllegalStateException("create qrCode error:remark is null");
        }
        if (Objects.isNull(period)) {
            throw new IllegalStateException("create qrCode error:period is null");
        }
        QrCodeData data = new QrCodeData();
        data.withId(SnowFlake.findUniqueId()).withHasTimeOut(false).withOwnerId(null)
                .withCreateTime(DateTimeUtils.getCurrentMillisecond()).withQrUrl(qrUrl)
                .withContainer(container).withPeriod(period).withRemark(remark);
        setData(data);
    }


    @Override
    public View getFullView() {
        return null;
    }

    @Override
    public View getViewLead(ViewSpec viewSpec) {
        return null;
    }
}
